from xml.dom.minidom import Document

file_num = 0

for file_num in range(0,1327):
    doc = Document()
    annotation = doc.createElement('annotation')
    annotation.setAttribute('verified','no')
    doc.appendChild(annotation)
    folder = doc.createElement('folder')
    folder_text = doc.createTextNode(str(file_num))
    folder.appendChild(folder_text)
    annotation.appendChild(folder)

    filename = doc.createElement('filename')
    filename_text = doc.createTextNode(str(file_num))
    filename.appendChild(filename_text)
    annotation.appendChild(filename)

    path = doc.createElement('path')
    path_text = doc.createTextNode("G:\\Lab need\\Dataset\\all_train_data_0829\\YDXJ0013\\0\\"+str(file_num)+".jpg")
    path.appendChild(path_text)
    annotation.appendChild(path)

    source = doc.createElement('source')
    database = doc.createElement('database')
    database_text = doc.createTextNode('Unknown')
    database.appendChild(database_text)
    source.appendChild(database)
    annotation.appendChild(source)

    size = doc.createElement('size')
    width = doc.createElement('width')
    height = doc.createElement('height')
    depth = doc.createElement('depth')
    width_text = doc.createTextNode('720')
    height_text = doc.createTextNode('405')
    depth_text = doc.createTextNode('3')
    width.appendChild(width_text)
    height.appendChild(height_text)
    depth.appendChild(depth_text)
    size.appendChild(width)
    size.appendChild(height)
    size.appendChild(depth)
    annotation.appendChild(size)

    segmented = doc.createElement('segmented')
    segmented_text = doc.createTextNode('0')
    segmented.appendChild(segmented_text)
    annotation.appendChild(segmented)
    outpath = 0
    if (file_num >= 0 and file_num < 10):
        outpath = "G:\\Lab need\\Dataset\\Varified Data\\Varified_xml\\val_000"+ str(file_num)+".xml"
    if (file_num >= 10  and  file_num < 100):
        outpath = "G:\\Lab need\\Dataset\\Varified Data\\Varified_xml\\val_00"+ str(file_num)+".xml"
    if (file_num >= 100 and file_num < 1000):
        outpath = "G:\\Lab need\\Dataset\\Varified Data\\Varified_xml\\val_0" + str(file_num) + ".xml"
    if (file_num >= 1000):
        outpath = "G:\\Lab need\\Dataset\\Varified Data\\Varified_xml\\val_" + str(file_num) + ".xml"
    out = open(outpath,"w")
    doc.writexml(out, indent='\t', addindent='\t', newl='\n', encoding="utf-8")
    out.close()

